import axios from "axios";
import { Message } from "element-ui";
// import {  } from "module";
// import router from '@/router'

const request = axios.create({
    baseURL: 'http://likede2-admin.itheima.net/likede/'
})

// 请求拦截器
request.interceptors.request.use(
    function (fonfig) {
        console.log(fonfig);
        // fonfig.headers.Authorization 
        return fonfig
    },
    function (error) {
        return Promise.reject(error)
    }
)

// 响应拦截器
request.interceptors.response.use(
    // 验证码错误的添加
    function (response) {
        if (response.data.msg === '验证码错误') {
            Message.error(response.data.msg)
            return Promise.reject(response)
        }
        return response
    },
    function (error) {
        return Promise.reject(error)
    }
)

export default request